package org.xlp.db.xml.ele;

import java.util.List;
import java.util.Objects;

/**
 * sqls中sql对象
 * 
 * @author 徐龙平
 * 
 * @version 1.0	
 */
public class SQLEle {
	/**
	 * 父ID
	 */
	private String parentId;

	//sql元素标记，在同一SQLs元素中的id不能相同
	private String id;
	//描述内容
	private String comment;
	//sql内容(可以包含order by和group by的内容)，当包含时，order by和group by内容可以不写
	private String sqlContent;
	//order by 内容
	private String orderBy;
	//group by 内容
	private String groupBy;
	//param对象
	private List<ParamEle> paramEles;

	/**
	 * 所在的sql配置文件信息
	 */
	private String fileDescription = "";
	
	public SQLEle(){}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public String getSqlContent() {
		return sqlContent;
	}

	public void setSqlContent(String sqlContent) {
		this.sqlContent = sqlContent;
	}

	public String getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}

	public String getGroupBy() {
		return groupBy;
	}

	public void setGroupBy(String groupBy) {
		this.groupBy = groupBy;
	}

	public List<ParamEle> getParamEles() {
		return paramEles;
	}

	public void setParamEles(List<ParamEle> paramEles) {
		this.paramEles = paramEles;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getFileDescription() {
		return fileDescription;
	}

	public void setFileDescription(String fileDescription) {
		this.fileDescription = fileDescription;
	}

	@Override
	public String toString() {
		return "SQLEle{" +
				"parentId='" + parentId + '\'' +
				", id='" + id + '\'' +
				", comment='" + comment + '\'' +
				", sqlContent='" + sqlContent + '\'' +
				", orderBy='" + orderBy + '\'' +
				", groupBy='" + groupBy + '\'' +
				", paramEles=" + paramEles +
				", fileDescription='" + fileDescription + '\'' +
				'}';
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		SQLEle sqlEle = (SQLEle) o;
		return Objects.equals(id, sqlEle.id)
				&& Objects.equals(parentId, sqlEle.parentId);
	}

	@Override
	public int hashCode() {
		return Objects.hash(parentId, id);
	}
}
